﻿using CefSharp;
using CefSharp.WinForms;
using System;
using System.IO;
using System.Windows.Forms;
using winformchrome.cef;
using winformchrome.server.controller;

namespace winformchrome
{
    public partial class BootForm : Form
    {
        public ChromiumWebBrowser webbrowser;

        public BootForm()
        {
            InitializeComponent();
            Control.CheckForIllegalCrossThreadCalls = false;

            CefSettings settings = new CefSettings();
            Cef.Initialize(settings);
            var fileName = Path.Combine(Directory.GetCurrentDirectory(), "page/index.html");
            webbrowser = new ChromiumWebBrowser(fileName) { Dock = DockStyle.Fill };

            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            webbrowser.RegisterJsObject("userController", new UserController(), new CefSharp.BindingOptions() { CamelCaseJavascriptNames = false });
            webbrowser.RegisterJsObject("appointmentController", new AppointmentController(), new CefSharp.BindingOptions() { CamelCaseJavascriptNames = false });
 

            this.Controls.Add(webbrowser);
            webbrowser.Dock = DockStyle.Fill;
            webbrowser.MenuHandler = new MenuHandler();
        }

        private void BootForm_Load(object sender, EventArgs e)
        {

        }
    }
}
